import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    // 全局变量
    state: {
        user: undefined,
        siteRoot: 'https://evp.51job.com/51job/api/51miniadmin/'
    },


    mutations: {
        login(state, payload) {
            state.user = payload
        },
        logout(state) {
            state.user = undefined
        }
    },

    actions: {
        login(context, payload) {
            context.commit('login', payload)
        },
        logout(context) {
            context.commit('logout')
        }
    }
})

export default store
